package com.zim.access;

import com.google.common.util.concurrent.AbstractService;
import com.google.common.util.concurrent.MoreExecutors;
import com.google.common.util.concurrent.Service;
import lombok.var;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

/**
 * @author hanyue
 * @version 1.0
 * @date 2021/12/21 下午9:55
 */
@SpringBootApplication
public class Application extends AbstractService {

    public static void main(String[] args) {
        var applicationContext = SpringApplication.run(Application.class, args);

        Application application = applicationContext.getBean(Application.class);

        application.addListener(new Service.Listener() {
            @Override
            public void running() {
                super.running();
            }

            @Override
            public void failed(State from, Throwable failure) {
                super.failed(from, failure);
            }
        }, MoreExecutors.directExecutor());

        application.startAsync();

        application.awaitTerminated();
    }

    @Override
    protected void doStart() {
        notifyStarted();
    }

    @Override
    protected void doStop() {
        notifyStopped();
    }
}
